<template>
    <ul class="nav-bar">
        <RouterLink to="/default" custom #="{ navigate,isActive }">
            <li :class="{ active:isActive }" @click="navigate()">欢迎页</li>
        </RouterLink>
        <li>
            <span>环境讲解</span>
            <ul class="child-menu">
                <RouterLink to="/error" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">欢迎页模块化错误和静态资源</li>
                </RouterLink>
                <RouterLink to="/style" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">欢迎页单位件样式</li>
                </RouterLink>
                <RouterLink to="/build" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">欢迎页模块项目打包</li>
                </RouterLink>
            </ul>
        </li>
        <li>
            <span>Vue组合式</span>
            <ul class="child-menu">
                <RouterLink to="/compos1" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">组合式Api</li>
                </RouterLink>
                <RouterLink to="/compos2" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">组合式Api语法1</li>
                </RouterLink>
                <RouterLink to="/compos3" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">组合式Api语法2</li>
                </RouterLink>
                <RouterLink to="/cart" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">购物车</li>
                </RouterLink>
            </ul>
        </li>
        <li>
            <span>异步请求</span>
            <ul class="child-menu">
                <RouterLink to="/ajax" custom #="{ navigate,isActive }">
                    <li :class="{ active:isActive }" @click="navigate()">axios的安装和基本使用</li>
                </RouterLink>
            </ul>
        </li>
        <li>
            <span>路由</span>
            <ul class="child-menu">
                <RouterLink to="/router" custom #="{ navigate,isActive,isExactActive }">
                    <li :class="{ active:isActive,'exact-active':isExactActive }" @click="navigate()">路由的基本使用</li>
                </RouterLink>
                <RouterLink to="/config" custom #="{ navigate,isActive,isExactActive }">
                    <li :class="{ active:isActive,'exact-active':isExactActive }" @click="navigate()">路由的配置</li>
                </RouterLink>
                <RouterLink to="/params" custom #="{ navigate,isActive,isExactActive }">
                    <li :class="{ active:isActive,'exact-active':isExactActive }" @click="navigate()">路由信息</li>
                </RouterLink>
                <RouterLink to="/login1" custom #="{ navigate,isActive,isExactActive }">
                    <li :class="{ active:isActive,'exact-active':isExactActive }" @click="navigate()">编程式导航</li>
                </RouterLink>
                <RouterLink to="/guard" custom #="{ navigate,isActive,isExactActive }">
                    <li :class="{ active:isActive,'exact-active':isExactActive }" @click="navigate()">路由守卫</li>
                </RouterLink>
            </ul>
        </li>
        <li>
            <span>vuex</span>
            <ul class="child-menu">
                <RouterLink to="/vuex" custom #="{ navigate,isActive,isExactActive }">
                    <li :class="{ active:isActive,'exact-active':isExactActive }" @click="navigate()">Vuex</li>
                </RouterLink>
            </ul>
        </li>
    </ul>
    <div class="box">
        <RouterView></RouterView>
    </div>
    <HomeBtn v-if="!$route.meta.hideHomeBtn"></HomeBtn>
</template>

<script>
import HomeBtn from "@/components/HomeBtn.vue"
export default {
    components:{
        HomeBtn
    }
}
</script>

<style scoped>
.nav-bar {
    /* 粘性定位 */
    position: sticky;
    top: 0px;
    left: 0px;
    height: 60px;
    line-height: 60px;
    display: flex;
    list-style: none;
    padding: 0px;
    margin: 0px;
    background-color: #333;
    box-shadow: 0 0 8px #666;
    padding: 0px 10px;
    z-index: 999;
}

.nav-bar>li {
    color: white;
    height: 100%;
    padding: 0px 10px;
    cursor: pointer;
    position: relative;
}

.nav-bar>li>span::after {
    font-family: "iconfont" !important;
    font-size: 18px;
    content: "\e620";
}

.nav-bar>li:hover {
    background-color: #932d08;
}

.nav-bar>li:hover .child-menu {
    display: block;
}

.nav-bar .child-menu {
    position: absolute;
    top: 60px;
    left: 0px;
    background-color: #555;
    list-style: none;
    padding: 0px;
    margin: 0px;
    box-shadow: 0 0 8px #888;
    display: none;
}

.nav-bar .child-menu>li {
    width: 250px;
    padding: 6px 16px;
    line-height: 2;
}

.nav-bar .child-menu>li:hover {
    background-color: #932d08;
}
.nav-bar .active{
    background-color: orange!important;
}
.nav-bar .exact-active{
    background-color: #932d08!important;
}
.box {
    padding: 20px;
}
</style>